$(function () {
    var timeout = null
    $(".dz>span>i").eq(0).mousedown(function () {
        console.log($(".dz>span>i"))
        timeout = setTimeout(function () {
            $(".dz>span>i").addClass("color");
        }, 1500)
    });

    $(".dz>span>i").eq(0).mouseup(function () {
        clearTimeout(timeout)
    });
})

$(function () {
    var timeout = null
    $(".dz>span>i").eq(0).mousedown(function () {
        // console.log($(this))
        timeout = setInterval(function () {
            $(".dz>span>i").eq(0).animate({ left: "-2px" }, 10)
                .animate({ left: "2px" }, 10)
                .animate({ left: 0 }, 10)
        }, 100)
        // console.log(timeout)
    })
    $(".dz>span>i").eq(0).mouseup(function () {
        clearInterval(timeout)
    })
})

$(function () {
    $(".fabuk #btn").click(function () {
        var xinxi = $('#txt').val();//输入内容
        // console.log(xinxi)
        if (xinxi == '') {
            alert("评论不能为空")
        } else {
            var plqsl = $(".plq").children().length + 1//子代长度
            var name = plqsl + "楼"

            var btint = parseInt($(".plbt span").text()) + 1 + '';
            $(".plbt span").text(btint)
            var shijan = nowtime();//当前时间

            var html = '<div class="pinlun">' +
                '<div class="pinglimg" >' + '<img src="img/\屏幕截图 2022-03-29 203514.png" alt=""></img>' + '</div >' +
                '<div class="pinglnr">' +
                '<p class="name">' + name + '</p>' +
                '<p class="text">' + xinxi + '</p>' +
                '<p class="xingxi">' +
                '<span class="shijian">' + shijan + '</span>' +
                '<span class="dianzai"><i class="fa fa-thumbs-o-up" aria-hidden="true"></i><b>0</b></span>' +
                '<span class="diancai"><i class="fa fa-thumbs-o-down" aria-hidden="true"></i></span>' +
                '<span class="huifu">回复</span>' +
                '</p>'
                + '<ul class="huifuq"></ul>' +
                '</div>' +
                '<div class="clearfix"></div>' + '<div class="clearfix"></div>' +
                '</div > '
            var html2 = $(html)
            $('.plq').append(html2);
            $('#txt').val('')
        }
        //获取当前时间
        function nowtime() {
            var myDate = new Date();
            var year = myDate.getFullYear();
            var month = myDate.getMonth() + 1;
            var date = myDate.getDate();
            var h = myDate.getHours();
            var m = myDate.getMinutes();
            var s = myDate.getSeconds();
            var now = year + '-' + p(month) + "-" + p(date) + " " + p(h) + ':' + p(m) + ":" + p(s);
            return now;
        }
        function p(s) {
            return s < 10 ? '0' + s : s;
        }
    })
})
$(function () {
    $(".plq").on("click", ".dianzai", function (e) {
        // console.log($(e.currentTarget).children('b'))
        if ($(e.currentTarget).hasClass('dzcolor')) {
            $(e.currentTarget).removeClass('dzcolor');
            $(e.currentTarget).children('b').html(parseInt($(this).text()) - 1 + "")
            console.log($(this).text())
        } else {
            $(e.currentTarget).addClass('dzcolor')
            // parseInt($(this).text())+1+""
            $(e.currentTarget).children('b').html(parseInt($(this).text()) + 1 + "")
            console.log($(this).text())
        }
    })

})
